package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-06-04
 * Time: 14:26
 */
//Test.java


class External{
    public String name;
    public int age;

    public External(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("父类构造方法执行");
    }
    {
        System.out.println("父类实例代码块执行");
    }
    static {
        System.out.println("父类静态代码块执行");
    }
}

class Internal extends External{
    public String name;
    public int age;

    public Internal(String name, int age) {
        super(name,age);
        this.name = name;
        this.age = age;
        System.out.println("子类构造方法执行");
    }
    {
        System.out.println("子类实例代码块执行");
    }
    static {
        System.out.println("子类静态代码块执行");
    }
}

public class Test {
    public static void main(String[] args) {
        Internal internal = new Internal("zhangsan",16);
        System.out.println("============");
        Internal internal1 = new Internal("lisi",18);

    }
}
